
package com.nuedu.corejava.ch10.homework;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class HomeWork7Teacher {
	public static void main(String[] args) {
		if (args == null || args.length == 0) {// 判断是否从控制台输入参数
			System.out.println("没有从控制台输入参数！");
			System.out.println("请输入一组单词，以逗号隔开 ！");
			Scanner scanner = new Scanner(System.in);
			String input = scanner.nextLine();
			args = input.split(",");
			
		}
		List<String> list = Arrays.asList(args);
		LinkedList<String> list2 = new LinkedList<String>(list);
		showInfo(list2);
		bubbleSortAsc(list2);
		showInfo(list2);
		
		
		

	}
	public static void showInfo(LinkedList<String> array) {
		for (String a:array) {
			System.out.print(a+"\t");
			
		}
		System.out.println();
	}

	public static void bubbleSortAsc(LinkedList<String> data) {
		String tmp = null;
		if (data == null) {
			return;
		}
		for (int i = 1; i < data.size(); i++) {
			for (int k = 0; k < data.size() - i; k++) {
				if (data.get(k).compareToIgnoreCase(data.get(i))>0) {// 大于号是升序
					tmp = data.get(k);
					data.set(k,data.get(k+1));
					data.set(k+1, tmp);
				}
			}

		}
	}
}
